<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset='UTF-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>Document</title>
  <script src='https://cdn.jsdelivr.net/npm/vue/dist/vue.js'></script>
</head>

<body>
  <div id='app'>
    <!-- <button @click="message++">+</button>
    <button @click="message--">-</button> -->
    <button @click="addClick">+</button>
    <button @click="subClick">-</button>
    <button @click="sayHello">hello</button>
    <h2>message:{{message}}</h2>
  </div>
  <script>
    const app = new Vue({
      // el: '#app', // el还可以是一个DOM对象
      el: document.getElementById('app'),
      // data() {
      //   return {
      //     message: 0
      //   }
      // }, // 可以是函数，也可以是对象，组件中必须是一个函数，避免组件复用的时候引起问题
      data: {
        message: 0
      },
      methods: {
        addClick() {
          this.message++
        },
        subClick() {
          this.message--
            // this['sayHello']() 
            // this.sayHello()
        },
        sayHello() {
          console.log('hello');
        }
      }
    })
  </script>
</body>

</html>